package io.gitee.kotle.demo.skin_view.skin

import android.view.View
import androidx.lifecycle.Observer

/**
 *
 * 描述：
 *
 * 创建人：jiale.wei
 * 创建时间：2022/2/9 1:52 下午
 *
 */


fun View.attachSkin(observer: Observer<BaseSkinPackage>) {
    addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
        override fun onViewAttachedToWindow(v: View) {
            SkinManage.skinData.observeForever(observer)
        }

        override fun onViewDetachedFromWindow(v: View) {
            SkinManage.skinData.removeObserver(observer)
        }
    })
}
